﻿using System;
using Gj;
using Gj.Pathfinding;
using UnityEngine;
using UnityEngine.UI;

public class MiniMapCamera : MiniMapItem
{
    public Camera camera;

    // var p = new Vector2(tp.x, tp.z);
    // p.x = p.x * map.ratio;
    // p.y = p.y * map.ratio;
    // p -= map.offset;
    // p.x = Math.Abs(p.x) > map.size.x ? map.size.x * (p.x > 0 ? 1 : -1) : p.x;
    // p.y = Math.Abs(p.y) > map.size.y ? map.size.y * (p.y > 0 ? 1 : -1) : p.y;
    protected override void UpdatePosition(MiniMap map)
    {
        var tp = SystemInput.center;
        var p = new Vector2(tp.x, tp.z);
        p.x = p.x * map.ratio;
        p.y = p.y * map.ratio;
        p -= map.offset;
        p.x = Math.Abs(p.x) > map.size.x ? map.size.x * (p.x > 0 ? 1 : -1) : p.x;
        p.y = Math.Abs(p.y) > map.size.y ? map.size.y * (p.y > 0 ? 1 : -1) : p.y;
        rect.anchoredPosition = p;
        transform.localScale = new Vector3(SystemInput.size.x * map.ratio, SystemInput.size.z * map.ratio, 1);
    }
}